#ifndef _CENARIOJOGO_H
#define _CENARIOJOGO_H

#include "Fundo.h"
#include "Tabuleiro.h"
#include "Jogador.h"
#include "CGFscene.h"
#include "Candeeiro.h"
#include "Jogada.h"
#include "Socket.h"
#include <time.h>
#include <iostream>
#include <iomanip>
#include <sstream>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
using std::stringstream;
using std::cout;
using std::endl;
using std::ends;

#define N 0
#define NE 1
#define E 2
#define SE 3
#define S 4
#define SW 5
#define W 6
#define NW 7

class CenarioJogo : public CGFscene
{
private:
	Socket* com;
	vector<Jogador *> players;
	vector<Jogada *> jogadas;
	int turn;
	CGFlight* light0;
	Tabuleiro* t;
	Candeeiro* cand;
	float x,y,dx,dy,xf,yf;
	int prevx,prevy,actualx,actualy;
	int timer;
	bool light,anim;
	vector<Peca> pecaanim;
	bool tumbling;
	int tumblingsize;
	clock_t start;
	clock_t endtime;
	int deslx;
	int desly;
	bool endgame;
	int winner;
	string gamemsg;
public:
	CenarioJogo(vector<Jogador *> jogadores);
	void init();
	void display();
	void toggleLight();
	bool processMovement(int xi, int yi, int fx, int fy, bool tumb);
	void setSimpleMoveAnimation(int xi, int yi, int fx, int fy);
	void setTumblingMoveAnimation(int xi, int yi, int dir);
	void getCPUPlay();
	void processUndo();
	void setSimpleMoveUndo(Jogada* jog);
	void setTumblingMoveUndo(Jogada* jog);
	void showPlayers();
	void showInfo();
	void drawString(const char *str, int x, int y, float color[4], void *font);
	int round(float num);
	void changeTexture();
	bool isCasaNotEmpty(int cx, int cy);
	bool isCasaOwner(int cx, int cy);
	bool isAnimating();
	string convertGameStatus();
	string convertCasa(int cx, int cy);
	void printPlayList();
	void changeTurn();
	int getTurn();
	Jogador* getPlayer(int j);
	bool canUndo();
	void select(int cx, int cy);
	void deselect();
	bool isGameOver();
	void endTheGame();
	void restartGame();
	void closeCom();
	void setMessage(string msg);
	void clearMessage();
};

#endif